<template>
  <div>
    <el-row class="tac">
      <el-col>
        <el-menu
          default-active="defaultActive"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
          unique-opened
          router
        >
          <el-menu-item index="/home">
            <i class="el-icon-house"></i>
            <span slot="title">首页</span>
          </el-menu-item>
          <el-submenu
            :index="idx.toString()"
            v-for="(item, idx) in getUser.menus"
            :key="item.id"
          >
            <template slot="title">
              <i :class="item.icon"></i>
              <span>{{ item.title }}</span>
            </template>
            <el-menu-item
              :index="child.url"
              v-for="child in item.children"
              :key="child.id"
              >{{ child.title }}</el-menu-item
            >
          </el-submenu>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      defaultActive: "/home",
    };
  },
  computed: {
    ...mapGetters(['getUser']),
  },
  mounted() {
    this.defaultActive = this.$route.path;
  },
};
</script>

<style lang="less" scoped>
.el-radio-group .el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
.el-menu {
  height: 88vh;
  text-align: left;
  overflow: hidden;
}
</style>
